#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
@author: xiaodun
@date: 2025/9/1820:22
"""
import os
import yaml
from pathlib import Path

BASE_DIR=Path(__file__).resolve().parent.parent

# print(os.path.join(BASE_DIR,'config','settings.yaml'))


class Config:
    def __init__(self):
        self.config_path=os.path.join(BASE_DIR,'config','base_info.yaml')
        with open(self.config_path,'r',encoding='utf-8') as f:
            self.setting=yaml.safe_load(f)
        self.env=os.getenv('TEST_ENV','test')#选择环境：test为测试环境
        self.browser_settings=self.setting['browser']
        self.env_settings=self.setting['environments'][self.env]

    def get_env_url(self):
        return self.env_settings['url']

    def get_username(self):
        return self.env_settings['username']

    def get_password(self):
        return self.env_settings['password']

    def get_browser_name(self):
        return self.browser_settings['name']

    def is_headless(self):
        return self.browser_settings['headless']

    def get_implicit_wait(self):#获取隐式等待时间
        return self.browser_settings['implicit_wait']

    def get_explicit_wait(self):#获取显示等待时间
        return self.browser_settings['explicit_wait']

config=Config()
# print(config.get_env_url())
# print(config.get_username())
# print(config.get_password())

# env=os.getenv('TEST_ENV','test')
# print(env)